<?php
class webpageController extends baseController{
    protected $installlockFile = '';
	public function __construct(){
        if( !isset( $_SESSION )) session_start();
        $this->installlockFile = BASE_PATH . 'install.lock';
        if(!file_exists($this->installlockFile)){
            $this->pageMsg('应用未初始安装!',0,url('install/index/index'));
        }
		define('__TPL__',rtrim(__ROOT__ . '/' . 'themes'));
        define('__TPLAPP__',rtrim(__ROOT__ . '/' . 'themes/' . APP_NAME));
		parent::__construct();
	}
    //模板显示  
    protected function display($tpl = '', $return = false, $is_tpl = true){
        if( $is_tpl ){
            $tpl = empty($tpl) ? CONTROLLER_NAME . '_'. ACTION_NAME : $tpl;
            if( $is_tpl && $this->layout ){
                $this->assign('__template_file',$tpl);
                $tpl = $this->layout;
            }
        }
        $this->view()->config['TPL_TEMPLATE_PATH'] = ROOT_PATH . 'themes/';
        $this->view()->addTags(api('cms', 'cmstpl'),true);
        $this->view()->assign($this->_data); 
        return $this->view()->display($tpl, $return, $is_tpl);
    }
    
    //随机数
    public function getcode($begin=0,$end=9,$limit=6){
        $rand_array=range($begin,$end); 
        shuffle($rand_array);  //调用现成的数组随机排列函数 
        $str = array_slice($rand_array,0,$limit);//截取前$limit个 
        return implode(null,$str);
    }
}